package com.lx.wxpush.utils;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author cVzhanshi
 * @create 2022-08-04 22:58
 */
public class CaiHongPiUtils {

    public static String getCaiHongPi(String key) {
        Map map = new HashMap<>();
        map.put("key", key);
        String result = HttpUtil.get("https://apis.tianapi.com/caihongpi/index", map);
        JSONObject jsonObject = JSONObject.parseObject(result);
        String content = jsonObject.getJSONObject("result").getString("content");
        return content;
    }


    public static String getWanAn(String key) {
        Map map = new HashMap<>();
        map.put("key", key);
        String result = HttpUtil.get("https://apis.tianapi.com/wanan/index", map);
        JSONObject jsonObject = JSONObject.parseObject(result);
        String content = jsonObject.getJSONObject("result").getString("content");
        return content;
    }

    public static Map getXingZuo(String key) {
        Map map = new HashMap<>();
        map.put("key", key);
        map.put("astro", "天蝎座");
        String result = HttpUtil.get("https://apis.tianapi.com/star/index", map);
        JSONObject jsonObject = JSONObject.parseObject(result);
        JSONArray content = jsonObject.getJSONObject("result").getJSONArray("list");
        Map data = new HashMap();
        for (int i = 0; i < content.size(); i++) {
            data.put(content.getJSONObject(i).getString("type"), content.getJSONObject(i).getString("content"));
        }
        return data;
    }

}
